package com.danieltoms.gcSync.addressbook.widgets;

import javax.microedition.pim.Contact;
import javax.microedition.pim.ContactList;
import javax.microedition.pim.PIM;
import javax.microedition.pim.PIMException;

import net.rim.blackberry.api.invoke.Invoke;
import net.rim.blackberry.api.invoke.MapsArguments;
import net.rim.device.api.ui.component.LabelField;

import com.danieltoms.gcSync.contact.BBContact;

public class ClickableAddressLabelField extends LabelField
{
	public ClickableAddressLabelField(String string)
	{
		super(string, HIGHLIGHT_FOCUS | FOCUSABLE);
	}

	protected boolean navigationClick(int status, int time)
	{
		super.navigationClick(status, time);

		ContactList list;
		try
		{
			list = (ContactList) PIM.getInstance().openPIMList(PIM.CONTACT_LIST, PIM.READ_WRITE);
			Contact temp = list.createContact();
			BBContact bc = new BBContact(temp);
			bc.setHomeAddress1("23 Forest Creek Cir");
			bc.setHomeAddress1("Chico, CA");
			MapsArguments args = new MapsArguments(bc.getContact(), 0);
			Invoke.invokeApplication(Invoke.APP_TYPE_MAPS, args);

		}
		catch (PIMException e)
		{
			// TODO Auto-generated catch block
			e.printStackTrace();
		}

		return true;
	}
}
